﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="UserInsert.aspx.cs" Inherits="WebSystem.User.UserInsert" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>添加管理员</title>
    <link href="../css/StyleforMemberRegister.css" type="text/css" rel="stylesheet" />

    <script language="javascript" type="text/javascript">
      //用户名检测
function chktxtMemberName(obj)
{
   document.getElementById("divMessageforloginnameservice").innerHTML="&nbsp;";

    var membername=obj.value;
    document.getElementById( "errspan1" ).className = "";
	document.getElementById( "errspan2" ).className = "";
	document.getElementById( "errspan3" ).className = "";
	changeUsernamePrompt("&nbsp;");
	if( membername == "" || membername == null ){
	document.getElementById("txtMemberNameforregiester").style.borderColor='red';
		changeUsernamePrompt( "请输入用户名，比如netease" + new Date().getFullYear() );
		return false;
	}
	var validFlag = isUsername( membername );
	if (validFlag != 0) {
		setError(validFlag);
		return false;
	}
	
	

	
	changeUsernamePrompt("用户名检测中......"); 
	
	
	var webserviceip="<%Response.Write(ConfigMg.UIConfig.cisWebServiceIP); %>";
	
	var webserviceurl=webserviceip+"/WebServiceforregister.asmx?WSDL";
	
	
	service.useService(webserviceurl,"myselect");
    service.myselect.callService(callback,"CheckMemberLoginNameIsUse",membername);
	
	return true;
}


function callback(res)
{
    if (!res.error)
    {
    var checkloginname=res.value;
    
    if(checkloginname=="usingnow")
	{
	
	    var showloginnamejy= document.getElementById("txtMemberNameforregiester").value;
	
	    
	
	    
	    
	
	    changeUsernamePrompt( "<font style=color:red>此用户名已被占用请更换后再试，比如"+showloginnamejy + new Date().getFullYear()+"</font>" );
		
	}
	else
	{
	   changeUsernamePrompt("恭喜，该用户名暂时未被抢注！");
	}
    
    
        //service.innerText=res.value;

//      xhai_GetXML(res.value);
    }
}


function setError(index)
{
	document.getElementById( "errspan1" ).className = "";
	document.getElementById( "errspan2" ).className = "";
	document.getElementById( "errspan3" ).className = "";
	document.getElementById( "errspan" + index ).className = "error";
	document.getElementById("txtMemberNameforregiester").style.borderColor='red';
	changeUsernamePrompt(document.getElementById( "errspan" + index ).innerHTML);
}

function isUsername( userName )
{
	var reg_re = new RegExp("[!@#$%\\^&\\*\\(\\)]","gi"); 
	var reg_space = new RegExp("[\\s]","gi");
	var reg_length = new RegExp("^.{5,20}$","gi");
	var reg_start = new RegExp("^[\\w_]*$","gi");
	var reg_validate = new RegExp("^([a-z]|[A-Z])[0-9a-zA-Z_]{4,19}$","g"); 
	var err = "";
	while ((arr = reg_re.exec(userName)) != null)
       err += arr;
	if (err != "") {
		//alert("-1");
		changeUsernamePrompt("用户名不能含有" + err.replace(/&/g, "&amp;"));
		return 1;
	} else if (reg_space.test(userName)) {		
		changeUsernamePrompt("用户名不能含有空格");
		return 1;
	}
	if(! reg_length.test( userName ) ){
		return 3;
	}
	if(! reg_start.test( userName ) ){		
		return 1;
	}
	if(! reg_validate.test( userName ) ){		
		return 2;
	}
	return 0;
}

function changeUsernamePrompt(cnt){
	document.getElementById( "divMessage" ).style.display="";
	//document.getElementById( "divRecommandName" ).style.display="none";
	document.getElementById( "failinfo" ).innerHTML = cnt;
}

function changeUserPwdPrompt(cntforpwd){
	document.getElementById( "divMessageforpwd" ).style.display="";
	//document.getElementById( "divRecommandName" ).style.display="none";
	document.getElementById( "failinfoforpwd" ).innerHTML = cntforpwd;
}


//密码检测
function chkpwd(obj){

var Bobj=document.getElementById("chkResult");

    Bobj.innerHTML="&nbsp;";
    var t=obj.value;
    document.getElementById( "errspan1forpwd" ).className = "";
	
	changeUserPwdPrompt("&nbsp;");
	if( t == "" || t == null ){
	document.getElementById("pwdBox").style.borderColor='red';
		changeUserPwdPrompt( "请输入密码");
		document.getElementById("errspan1forpwd").className='error';
		return false;
	}
	
	var id=getResult(t);
	
	
	if(id==0)
	{
	    document.getElementById("pwdBox").style.borderColor='red';
	    
		document.getElementById("errspan1forpwd").className='error';
	    changeUserPwdPrompt(document.getElementById("errspan1forpwd").innerHTML);
		return false;
	}
	else
	{
	
	    //定义对应的消息提示
	    var msg=new Array(4);
	    msg[0]="密码过短。";
	    msg[1]="密码强度差。";
	    msg[2]="密码强度良好。";
	    msg[3]="密码强度高。";
    	
	    var sty=new Array(4);
	    sty[0]=-45;
	    sty[1]=-30;
	    sty[2]=-15;
	    sty[3]=0;
    	
	    var col=new Array(4);
	    col[0]="red";
	    col[1]="gray";
	    col[2]="#ff6600";
	    col[3]="Green";
    	
	    //设置显示效果
	    //var bImg="../sysImages/user/qd.gif";//一张显示用的图片
	    var sWidth=300;
	    var sHeight=15;
    	

	    Bobj.style.fontSize="12px";
	    Bobj.style.color=col[id];
	    Bobj.style.width=sWidth + "px";
	    Bobj.style.height=sHeight + "px";
	    Bobj.style.lineHeight=sHeight + "px";
	    //Bobj.style.background="url(" + bImg + ") no-repeat left " + sty[id] + "px";
	    Bobj.style.textIndent="20px";
	   Bobj.innerHTML="检测提示：" + msg[id];       
	}
	
	
//	if(document.getElementById( "pwdsBox" ).value!=null||document.getElementById( "pwdsBox" ).value!="")
//	{
//	    chkpwds(document.getElementById( "pwdsBox" ).value);
//	}
	
	
	return true;
}

//定义检测函数,返回0/1/2/3分别代表无效/差/一般/强
function getResult(s){
 
	if(s.length < 6&& s.length>0){
		return 0;
	}
	var ls = 0;
	if (s.match(/[a-z]/ig)){
		ls++;
	}
	if (s.match(/[0-9]/ig)){
		ls++;
	}
 	if (s.match(/(.[^a-z0-9])/ig)){
		ls++;
	}
	if (s.length < 6 && ls > 0){
		ls--;
	}
	return ls
}


//确认密码检测
function chkpwds(obj)
{
     var strpwds=obj.value;
     var strpwd=document.getElementById( "pwdBox" ).value;
     
     document.getElementById( "errspan1forpwds" ).className = "";
	
	changeUserPwdsPrompt("&nbsp;");
	if( strpwds == "" || strpwds == null ){
	document.getElementById("pwdsBox").style.borderColor='red';
		changeUserPwdsPrompt( "请输入确认密码");
		document.getElementById("errspan1forpwds").className='error';
		return false;
	}
	
	if(strpwds!=strpwd)
	{
	    document.getElementById("pwdsBox").style.borderColor='red';
		changeUserPwdsPrompt(document.getElementById("errspan1forpwds").innerHTML);
		document.getElementById("errspan1forpwds").className='error';
		return false;
	}
	return true;
	
	
	
     
}
function changeUserPwdsPrompt(strforpwds)
{
    document.getElementById( "divMessageforpwds" ).style.display="";
	
	document.getElementById( "failinfoforpwds" ).innerHTML = strforpwds;
}






//确认用户真实姓名
function chktxtRealName(obj)
{
     var strrealname=obj.value;
     document.getElementById( "errspan1forrealname" ).className = "";
	
	changerealnamePrompt("&nbsp;");
	if( strrealname == "" || strrealname == null ){
	document.getElementById("txtRealName").style.borderColor='red';
		changerealnamePrompt( document.getElementById( "errspan1forrealname" ).innerHTML);
		document.getElementById("errspan1forrealname").className='error';
		return false;
	}
	return true;
  
}
function changerealnamePrompt(strforrealname)
{
    document.getElementById( "divMessageforrealname" ).style.display="";
	document.getElementById( "failinfoforrealname" ).innerHTML = strforrealname;
}


function fLen(Obj){
  var nCNLenth = 0;
  var nLenth = Obj.length;
  for (var i=0; i<nLenth; i++){
    if(Obj.charCodeAt(i)>255){
      nCNLenth += 2; 
    }else{
      nCNLenth++;
    }
  }
  return nCNLenth;
}






//终验
function zongcheck()
{
//    document.getElementById( "divMessageforvalicode2" ).innerHtml = "&nbsp;";
    var zongcheckforall=true;
    zongcheckforall=chktxtMemberName(document.getElementById("txtMemberNameforregiester"));
    
    if(!zongcheckforall)
    {
        return zongcheckforall;
    }
    

    
    
    zongcheckforall=chkpwd(document.getElementById("pwdBox"));
    
     if(!zongcheckforall)
    {
        return zongcheckforall;
    }
    
    zongcheckforall=chkpwds(document.getElementById("pwdsBox"));
    
     if(!zongcheckforall)
    {
        return zongcheckforall;
    }

    

    
    
    zongcheckforall=chktxtRealName(document.getElementById("txtRealName"));
    
     if(!zongcheckforall)
    {
        return zongcheckforall;
    }
    
   
    

    
   
  
    
    

}
    </script>

</head>
<body style="background-color:#fcf6ec">
    <form id="form1" runat="server">
        <%--间隔--%>
        <table cellpadding="0" cellspacing="0" border="0" width="800px">
            <tr>
                <td height="20px">
                </td>
            </tr>
        </table>
        <table cellpadding="0" cellspacing="0" border="0" width="800px">
            <tr>
                <td height="20px">
                    <font style="color: #426F98; font-family: 宋体; font-weight: bold; font-size: 14px;">管理员添加</font>
                </td>
            </tr>
        </table>
        <%--间隔--%>
        <table cellpadding="0" cellspacing="0" border="0" width="800px">
            <tr>
                <td height="20px">
                </td>
            </tr>
        </table>

        <!--会员注册账号密码信息-->
        <table cellpadding="0" cellspacing="0" border="0" width="800px">
            <!--会员注册名-->
            <tr>
                <td class="leftforregister">
                    登录名：
                </td>
                <td class="centerforregister">
                    <asp:TextBox ID="txtMemberNameforregiester" runat="server" Width="184px" MaxLength="20"
                        onfocus="this.style.borderColor='#000000'" onblur="this.style.borderColor='#A3BFA8';chktxtMemberName(this);"></asp:TextBox>
                    <div id="divMessageforloginnameservice" runat="server">
                    </div>
                    <div id="service" style="behavior: url(webservice.htc)">
                    </div>
                </td>
                <td class="rightforregister">
                    <span id="errspan1">用户名只能由英文字母a～z(不区分大小写)、数字0～9、下划线组成。</span><br />
                    <span id="errspan2">用户名的起始字符必须是英文字母。如：netease_2005 </span>
                    <br />
                    <span id="errspan3">用户名长度为5～20个字符。</span><br />
                </td>
            </tr>
            <!--会员名检测结果-->
            <tr height="20px">
                <td class="leftforregister">
                </td>
                <td class="jyjgforregister" colspan="2">
                    <div id="divMessage" style="display: none">
                        <span id="failinfo"></span>
                    </div>
                </td>
            </tr>
            <!--密码-->
            <tr>
                <td class="leftforregister">
                    密码：
                </td>
                <td class="centerforregister">
                    <asp:TextBox ID="pwdBox" runat="server" Width="184px" MaxLength="18" TextMode="Password"
                        onfocus="this.style.borderColor='#000000'" onblur=" this.style.borderColor='#A3BFA8';chkpwd(this);"></asp:TextBox>
                </td>
                <td class="rightforregister">
                    <span id="errspan1forpwd">密码长度6～18位，由英文字母a～z (区分大小写)，数字0～9，特殊字符组成。</span><br />
                </td>
            </tr>
            <!--密码检测结果-->
            <tr height="20px">
                <td class="leftforregister">
                </td>
                <td class="jyjgforregister" colspan="2">
                    <div id="divMessageforpwd" style="display: none">
                        <span id="failinfoforpwd"></span>
                    </div>
                    <span id="chkResult"></span>
                </td>
            </tr>
            <!--确认密码-->
            <tr>
                <td class="leftforregister">
                    确认密码：
                </td>
                <td class="centerforregister">
                    <asp:TextBox ID="pwdsBox" runat="server" Width="184px" TextMode="Password" onfocus="this.style.borderColor='#000000'"
                        onblur=" this.style.borderColor='#A3BFA8';chkpwds(this);"></asp:TextBox>
                </td>
                <td class="rightforregister">
                    <span id="errspan1forpwds">确认密码应与密码一致。</span><br />
                </td>
            </tr>
            <!--密码检测结果-->
            <tr height="20px">
                <td class="leftforregister">
                </td>
                <td class="jyjgforregister" colspan="2">
                    <div id="divMessageforpwds" style="display: none">
                        <span id="failinfoforpwds"></span>
                    </div>
                </td>
            </tr>
            <!--所属组名称-->
            <tr>
                <td class="leftforregister">
                    请选择角色：
                </td>
                <td class="centerforregister">
                    <asp:DropDownList ID="ddlUserGroupParent" runat="server">
                    </asp:DropDownList>
                    <%--<asp:TextBox ID="txtFolderName" runat="server" Width="184px" MaxLength="64" onfocus="this.style.borderColor='#000000'"  onblur="this.style.borderColor='#A3BFA8';chktxtFolderName(this);"></asp:TextBox>--%>
                    <%--<asp:TextBox ID="txtFolderRemark" runat="server" Width="250px" Height="150px" TextMode="MultiLine"></asp:TextBox>--%>
                </td>
                <td class="rightforregister">
                    <span id="Span1">请选择角色</span><br />
                </td>
            </tr>
            <tr height="20px">
                <td class="leftforregister">
                </td>
                <td class="jyjgforregister" colspan="2">
                    <div style="display: none">
                        <span></span>
                    </div>
                </td>
            </tr>
            
            <tr style="display:none">
                <td class="leftforregister">
                    请选择所属部门：
                </td>
                <td class="centerforregister">
                    <asp:DropDownList ID="ddl_Unit" runat="server">
                    </asp:DropDownList>
                    <%--<asp:TextBox ID="txtFolderName" runat="server" Width="184px" MaxLength="64" onfocus="this.style.borderColor='#000000'"  onblur="this.style.borderColor='#A3BFA8';chktxtFolderName(this);"></asp:TextBox>--%>
                    <%--<asp:TextBox ID="txtFolderRemark" runat="server" Width="250px" Height="150px" TextMode="MultiLine"></asp:TextBox>--%>
                </td>
                <td class="rightforregister">
                    <span id="Span4" runat="server">请选择所属部门</span><br />
                </td>
            </tr>
            <tr height="20px" style="display:none">
                <td class="leftforregister">
                </td>
                <td class="jyjgforregister" colspan="2">
                    <div style="display: none">
                        <span></span>
                    </div>
                </td>
            </tr>
        </table>
        <!--会员注册详细资料-->
        <table cellpadding="0" cellspacing="0" border="0" width="800px">
            <!--真实姓名-->
            <tr>
                <td class="leftforregister">
                    真实姓名：
                </td>
                <td class="centerforregister">
                    <asp:TextBox ID="txtRealName" runat="server" Width="184px" MaxLength="20" onfocus="this.style.borderColor='#000000'"
                        onblur="this.style.borderColor='#A3BFA8';chktxtRealName(this);"></asp:TextBox>
                </td>
                <td class="rightforregister">
                    <span id="errspan1forrealname">请填写真实姓名。</span><br />
                </td>
            </tr>
            <!--真实姓名检测结果-->
            <tr height="20px">
                <td class="leftforregister">
                </td>
                <td class="jyjgforregister" colspan="2">
                    <div id="divMessageforrealname" style="display: none">
                        <span id="failinfoforrealname"></span>
                    </div>
                </td>
            </tr>
            
            
            <!--职位-->
            <tr style="display:none">
                <td class="leftforregister">
                    职位：
                </td>
                <td class="centerforregister">
                    <asp:TextBox ID="txtJoblName" runat="server" Width="184px" MaxLength="20" onfocus="this.style.borderColor='#000000'"
                        onblur="this.style.borderColor='#A3BFA8';" Text="管理员"></asp:TextBox>
                </td>
                <td class="rightforregister">
                    <span id="Span2">请填写职位。</span><br />
                </td>
            </tr>
            <!--职位检测结果-->
            <tr height="20px" style="display:none">
                <td class="leftforregister">
                </td>
                <td class="jyjgforregister" colspan="2">
                    <asp:RequiredFieldValidator
                            ID="RequirestyleLabeltxtJoblName" runat="server" ControlToValidate="txtJoblName"
                            Display="Dynamic" ErrorMessage="<span class=reshow>请填写职位名称</span>"></asp:RequiredFieldValidator>
                </td>
            </tr>
            
            <!--电话-->
            <tr>
                <td class="leftforregister">
                    手机：
                </td>
                <td class="centerforregister">
                    <asp:TextBox ID="txtPhone" runat="server" Width="184px" MaxLength="20" onfocus="this.style.borderColor='#000000'"
                        onblur="this.style.borderColor='#A3BFA8';"></asp:TextBox>
                </td>
                <td class="rightforregister">
                    <span id="Span3">请填写手机。</span><br />
                </td>
            </tr>
            <!--手机检测结果-->
            <tr height="20px">
                <td class="leftforregister">
                </td>
                <td class="jyjgforregister" colspan="2">
                    <asp:RequiredFieldValidator
                            ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtPhone"
                            Display="Dynamic" ErrorMessage="<span class=reshow>请填写手机</span>"></asp:RequiredFieldValidator>
                            <span style="color:Red">
                            <asp:Label ID="lblPhone" runat="server"></asp:Label></span>
                </td>
            </tr>
            
            <%--按钮提交--%>
            <tr>
                <td class="leftforregister">
                </td>
                <td class="jyjgforregister" colspan="2">
                    <asp:ImageButton ID="ibtnadd" runat="server" ImageUrl="../images/Basic/xinzeng.gif"
                        ToolTip="添加" OnClientClick="javascript:return zongcheck();" OnClick="ibtnadd_Click" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <asp:ImageButton ID="ibtnback" runat="server" ImageUrl="../images/Basic/return.gif"
                        ToolTip="返回" OnClick="ibtnback_Click" CausesValidation="false"/>
                </td>
            </tr>
        </table>
        <%--原逻辑--%>
        <%-- <div style="text-align: center">
        <h1>
            添加管理员</h1>
        <div>
            UserName:<asp:TextBox ID="txtUserName" runat="server"></asp:TextBox>
        </div>
        <div>
            UserPassword:<asp:TextBox ID="txtUserPassword" runat="server"></asp:TextBox>
        </div>
        <div>
            UserGruop:<asp:DropDownList ID="ddlBoss" runat="server">
            </asp:DropDownList>
        </div>
        <div>
            <asp:Button ID="btnInsert" runat="server" Text="Insert" 
                onclick="btnInsert_Click"  />&nbsp;&nbsp;<asp:Button
                ID="btnReset" runat="server" Text="Reset" />
        </div>
       </div>--%>
    </form>
</body>
</html>
